//
//  PNPacket.h
//  iRctl
//
//  Created by 城门虾米 on 2019/7/31.
//  Copyright © 2019 A. All rights reserved.
//

#import <Foundation/Foundation.h>

NS_ASSUME_NONNULL_BEGIN


enum PNPacketStreamType {
    kPNPacketStreamTouch = 0,
    kPNPacketStreamH264 = 1,
    kPNPacketStreamAAC = 2,
    kPNPacketStreamPCM = 3,
    kPNPacketStreamAndroidVideoStart = 6,
    kPNPacketStreamH264WithTimestamp = 12,
    kPNPacketStreamTimestamp = 13
};

enum PNPacketType {
    kPNPacketTypeControl = 1,
    kPNPacketTypeStream  = 2
};

enum {
    MSGID_REQ_PING_C                = 0x0001,
    MSGID_RES_PONG_C                = 0x0002,

    MSGID_REQ_USER_CONNECT          = 0x0102,   // user connect to stream server {connect_id, device_ip}
    MSGID_RES_USER_CONNECT          = 0x0202,   // user connect to stream server response {errno, error}
};



@interface PNPacket : NSObject

@property (nonatomic) int8_t          packetType; ///< 1表示 控制消息 2表示
@property (nonatomic) int32_t         packetID;
@property (nonatomic) int16_t          messageID; ///< 消息ID
@property (nonatomic) NSDictionary*    messageBody; ///< 表示控制消息体
@property (nonatomic) NSData*        data; ///< 完整二进制数据流

@property (nonatomic) int8_t         streamType; ///< 流数据流
@property (nonatomic) NSData*        streamData; ///< 流数据流

+ (instancetype)packetWithBytes:(nullable const void *)bytes length:(NSUInteger)length;

+ (instancetype)packetWithPacketID:(int32_t)packetID msgID:(int16_t)msgID content:(NSDictionary*)content;

+ (instancetype)packetWithStreamType:(int8_t)streamType streamData:(NSData *)data;

+ (int32_t)maybePacketWithBytes:(const void *)bytes length:(NSUInteger)length;

@end

NS_ASSUME_NONNULL_END
